﻿<!DOCTYPE html>
<html>

<head>
	<title></title>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="stylesheet" href="assets/css/bootstrap.min.css">
</head>

<body>
	<div class="wrapper" style="padding: 10px;">
		<div class="content-main">
			<h3 class="text-center">管理员授权登录</h3>
			<div id="wechatUser" class="text-center" style="padding-bottom: 30px;">
				<img src="assets/images/avatar.jpg" alt="" class="img-circle" width="60" height="60">
				<h4>微信昵称</h4>
			</div>
			<div id="bound" style="display: none;">
				<div class="container" style="font-size: 18px; padding-bottom: 60px;">
					<div class="row">
						<div class="col-xs-6 text-right" style="margin: 0 -12px;">设备识别码：</div>
						<div class="col-xs-6" id="confirmFlag" style="margin: 0 -12px;"></div>
					</div>
					<div class="row">
						<div class="col-xs-6 text-right" style="margin: 0 -12px;">设备IP：</div>
						<div class="col-xs-6" id="confirmIp" style="margin: 0 -12px;"></div>
					</div>
					<div class="row">
						<div class="col-xs-6 text-right" style="margin: 0 -12px;">设备位置：</div>
						<div class="col-xs-6" id="confirmLocation" style="margin: 0 -12px;"></div>
					</div>
					<div class="row">
						<div class="col-xs-6 text-right" style="margin: 0 -12px;">登录账号：</div>
						<div class="col-xs-6" id="confirmAccount" style="margin: 0 -12px;"></div>
					</div>
				</div>
				<button type="button" class="btn btn-primary btn-lg btn-block" id="btnConfirm">确认登录</button>
				<button type="button" class="btn btn-default btn-lg btn-block" id="refresh">刷新缓存</button>
			</div>
			<div id="unbind" style="display: none;">
				<p style="text-align: center; font-size: 18px;">您还未绑定管理员账号，前往<a href="admin_apply.html">申请</a>。</p>
			</div>
			<div id="authSuccess" style="display: none;">
				<p style="text-align: center; font-size: 18px;">授权成功！</p>
			</div>
		</div>
	</div>
	<script src="assets/js/jquery-1.8.1.min.js"></script>
	<script src="assets/js/jquery.cookie.js"></script>
	<script src="assets/js/bootstrap.min.js"></script>
	<script src="assets/js/common.js"></script>
	<script type="text/javascript">
		httpRequest("/wechat/Admin/getAuthInfo", {
			uuid: getQueryString('udid'),
		}, function (data) {
			$('#wechatUser img').attr('src', data.headimgurl);
			$('#wechatUser h4').html(data.nickname);
			if (data.bound) {
				$('#confirmFlag').html(data.flag);
				$('#confirmIp').html(data.ip);
				$('#confirmLocation').html(data.location);
				$('#confirmAccount').html(data.account);
				$('#bound').show();
			} else {
				$('#unbind').show();
			}
		});
		$("#btnConfirm").click(function () {
			httpRequest("/wechat/Admin/confirmAuth", {
				uuid: getQueryString('udid'),
			}, function () {
				$('#bound').hide();
				$('#authSuccess').show();
			});
		});
		$("#refresh").click(function () {
			httpRequest("/wechat/Admin/refresh", {});
		});
		$('#wechatUser img').on('error', function () {
			$(this).attr('src', 'assets/images/avatar.jpg');
			$(this).unbind("error");
		});
	</script>
</body>

</html>